home *** CD-ROM | disk | FTP | other *** search
- /* math.h standard header */
- #ifdef __MWERKS__
-
- #ifndef __MATH__
- #define __MATH__
-
- #pragma options align=mac68k
-
- /* common macros */
- #define _PI pi
- #define HUGE_VAL __inf()
-
- /*
- * Set the following define to 1 to force the ANSI math header to inline FPU calls
- * whenever possible. This behaviour is not ANSI compatible, so should be used with
- * care.
- * NB: on 680x0 macs, using inlines in conjunction with 8byte doubles will not work
- * correctly.
- */
- #if !defined(_INLINE_FPU_CALLS_)
- #define _INLINE_FPU_CALLS_ 0
- #endif
-
- /* common type definitions */
- typedef union {
- unsigned short _W[5];
- float _F;
- double _D;
- long double _L;
- } _Dconst;
-
- #ifndef _YVALS
- #include <yvals.h>
- #endif
-
- /* function prototype declarations (common to both 68K and PPC) */
- _C_LIB_DECL
- /* float declarations */
- float cosf(float);
- float sinf(float);
- float tanf(float);
- float acosf(float);
- float asinf(float);
- float atanf(float);
- float atan2f(float, float);
- float coshf(float);
- float sinhf(float);
- float tanhf(float);
- float expf(float);
- float frexpf(float, int *);
- float ldexpf(float, int);
- float logf(float);
- float log10f(float);
- float modff(float, float*);
- float fabsf(float);
- float powf(float, float);
- float sqrtf(float);
- float ceilf(float);
- float floorf(float);
- float fmodf(float, float);
- /* double declarations */
- double cos(double);
- double sin(double);
- double tan(double);
- double acos(double);
- double asin(double);
- double atan(double);
- double atan2(double, double);
- double cosh(double);
- double sinh(double);
- double tanh(double);
- double exp(double);
- double frexp(double, int *);
- double ldexp(double, int);
- double log(double);
- double log10(double);
- double modf(double, double *);
- double fabs(double);
- double pow(double, double);
- double sqrt(double);
- double ceil(double);
- double floor(double);
- double fmod(double, double);
- _END_C_LIB_DECL
-
- #if powerc
-
- /* constants */
- extern const double pi;
- /* function prototypes */
- _C_LIB_DECL
- /* infinity function */
- double __inf ( void );
-
- /* inline fabs call */
- #if _INLINE_FPU_CALLS_
- #define fabs(x) __fabs(x)
- #endif
- _END_C_LIB_DECL
-
- #else /* !powerc */
-
- /* constants */
- extern const long double pi;
- /* function prototypes */
- _C_LIB_DECL
- /* infinity function */
- long double __inf ( void );
-
- /* double macro overrides */
- #if _INLINE_FPU_CALLS_ && __MC68881__
- /* call the FPU directly (NOT ANSI COMPATIBLE) */
- long double _fpucos(long double:__FP0):__FP0 = { 0xF200,0x001D };
- long double _fpusin(long double:__FP0):__FP0 = { 0xF200,0x000E };
- long double _fputan(long double:__FP0):__FP0 = { 0xF200,0x000F };
- long double _fpuacos(long double:__FP0):__FP0 = { 0xF200,0x001C };
- long double _fpuasin(long double:__FP0):__FP0 = { 0xF200,0x000C };
- long double _fpuatan(long double:__FP0):__FP0 = { 0xF200,0x000A };
- long double _fpucosh(long double:__FP0):__FP0 = { 0xF200,0x0019 };
- long double _fpusinh(long double:__FP0):__FP0 = { 0xF200,0x0002 };
- long double _fputanh(long double:__FP0):__FP0 = { 0xF200,0x0009 };
- long double _fpuexp(long double:__FP0):__FP0 = { 0xF200,0x0010 };
- long double _fpuldexp(long double:__FP0,long:__D0):__FP0 = { 0xF200,0x4026 };
- long double _fpulog(long double:__FP0):__FP0 = { 0xF200,0x0014 };
- long double _fpulog10(long double:__FP0):__FP0 = { 0xF200,0x0015 };
- long double _fpufabs(long double:__FP0):__FP0 = { 0xF200,0x0018 };
- long double _fpusqrt(long double:__FP0):__FP0 = { 0xF200,0x0004 };
- long double _fpufmod(long double:__FP0,long double:__FP1):__FP0 = { 0xF200,0x0421 };
- #define cos(x) _fpucos(x)
- #define sin(x) _fpusin(x)
- #define tan(x) _fputan(x)
- #define acos(x) _fpuacos(x)
- #define asin(x) _fpuasin(x)
- #define atan(x) _fpuatan(x)
- #define cosh(x) _fpucosh(x)
- #define sinh(x) _fpusinh(x)
- #define tanh(x) _fputanh(x)
- #define exp(x) _fpuexp(x)
- #define ldexp(x,n) _fpuldexp(x,n)
- #define log(x) _fpulog(x)
- #define log10(x) _fpulog10(x)
- #define fabs(x) _fpufabs(x)
- #define sqrt(x) _fpusqrt(x)
- #define fmod(x,y) _fpufmod(x,y)
- #else
- /* ANSI compatible double overrides */
- double cosd(double);
- double sind(double);
- double tand(double);
- double acosd(double);
- double asind(double);
- double atand(double);
- double coshd(double);
- double sinhd(double);
- double tanhd(double);
- double expd(double);
- double ldexpd(double, int);
- double logd(double);
- double log10d(double);
- double fabsd(double);
- double sqrtd(double);
- double fmodd(double, double);
- #define cos(x) cosd(x)
- #define sin(x) sind(x)
- #define tan(x) tand(x)
- #define acos(x) acosd(x)
- #define asin(x) asind(x)
- #define atan(x) atand(x)
- #define cosh(x) coshd(x)
- #define sinh(x) sinhd(x)
- #define tanh(x) tanhd(x)
- #define exp(x) expd(x)
- #define ldexp(x,n) ldexpd(x,n)
- #define log(x) logd(x)
- #define log10(x) log10d(x)
- #define fabs(x) fabsd(x)
- #define sqrt(x) sqrtd(x)
- #define fmod(x,y) fmodd(x,y)
- #endif
- /* following cannot be inlined */
- double atan2d(double, double);
- double frexpd(double, int *);
- double modfd(double, double *);
- double powd(double, double);
- double ceild(double);
- double floord(double);
- #define atan2(x,y) atan2d(x,y)
- #define frexp(x,exp) frexpd(x,exp)
- #define modf(x,iptr) modfd(x,iptr)
- #define pow(x,y) powd(x,y)
- #define ceil(x) ceild(x)
- #define floor(x) floord(x)
- /* long double declarations */
- long double cosl(long double);
- long double sinl(long double);
- long double tanl(long double);
- long double acosl(long double);
- long double asinl(long double);
- long double atanl(long double);
- long double atan2l(long double, long double);
- long double coshl(long double);
- long double sinhl(long double);
- long double tanhl(long double);
- long double expl(long double);
- long double frexpl(long double, int *);
- long double ldexpl(long double, int);
- long double logl(long double);
- long double log10l(long double);
- long double modfl(long double, long double *);
- long double fabsl(long double);
- long double powl(long double, long double);
- long double sqrtl(long double);
- long double ceill(long double);
- long double floorl(long double);
- long double fmodl(long double, long double);
- /* internally used functions */
- double _Sinh(double, double);
- double _Cosh(double, double);
- long double _LCosh(long double, long double);
- long double _LSinh(long double, long double);
- _END_C_LIB_DECL
-
- #endif /* powerc */
-
- #pragma options align=reset
-
- #endif /* __MATH__ */
-
- #else /* !__MWERKS__ */
-
- #ifndef _MATH
- #define _MATH
- #include <yvals.h>
- /* macros */
- #define HUGE_VAL _Hugeval._D
- /* type definitions */
- #if defined(__CENTERLINE__)
- typedef struct {
- #else
- typedef union {
- #endif
- unsigned short _W[5];
- float _F;
- double _D;
- long double _L;
- } _Dconst;
- _C_LIB_DECL
- /* double declarations */
- double acos(double);
- double asin(double);
- double atan(double);
- double atan2(double, double);
- double ceil(double);
- double exp(double);
- double fabs(double);
- double floor(double);
- double fmod(double, double);
- double frexp(double, int *);
- double ldexp(double, int);
- double modf(double, double *);
- double pow(double, double);
- double sqrt(double);
- double tan(double);
- double tanh(double);
- double _Cosh(double, double);
- double _Log(double, int);
- double _Sin(double, unsigned int);
- double _Sinh(double, double);
- extern const _Dconst _Hugeval;
- /* float declarations */
- float acosf(float);
- float asinf(float);
- float atanf(float);
- float atan2f(float, float);
- float ceilf(float);
- float expf(float);
- float fabsf(float);
- float floorf(float);
- float fmodf(float, float);
- float frexpf(float, int *);
- float ldexpf(float, int);
- float modff(float, float *);
- float powf(float, float);
- float sqrtf(float);
- float tanf(float);
- float tanhf(float);
- float _FCosh(float, float);
- float _FLog(float, int);
- float _FSin(float, unsigned int);
- float _FSinh(float, float);
- /* long double declarations */
- long double acosl(long double);
- long double asinl(long double);
- long double atanl(long double);
- long double atan2l(long double, long double);
- long double ceill(long double);
- long double expl(long double);
- long double fabsl(long double);
- long double floorl(long double);
- long double fmodl(long double, long double);
- long double frexpl(long double, int *);
- long double ldexpl(long double, int);
- long double modfl(long double, long double *);
- long double powl(long double, long double);
- long double sqrtl(long double);
- long double tanl(long double);
- long double tanhl(long double);
- long double _LCosh(long double, long double);
- long double _LLog(long double, int);
- long double _LSin(long double, unsigned int);
- long double _LSinh(long double, long double);
- _END_C_LIB_DECL
- #ifdef __cplusplus
- /* double inlines, for C++ */
- inline double cos(double _X)
- {return (_Sin(_X, 1)); }
- inline double cosh(double _X)
- {return (_Cosh(_X, 1)); }
- inline double log(double _X)
- {return (_Log(_X, 0)); }
- inline double log10(double _X)
- {return (_Log(_X, 1)); }
- inline double sin(double _X)
- {return (_Sin(_X, 0)); }
- inline double sinh(double _X)
- {return (_Sinh(_X, 1)); }
- /* float inlines, for C++ */
- inline float cosf(float _X)
- {return (_FSin(_X, 1)); }
- inline float coshf(float _X)
- {return (_FCosh(_X, 1)); }
- inline float logf(float _X)
- {return (_FLog(_X, 0)); }
- inline float log10f(float _X)
- {return (_FLog(_X, 1)); }
- inline float sinf(float _X)
- {return (_FSin(_X, 0)); }
- inline float sinhf(float _X)
- {return (_FSinh(_X, 1)); }
- /* long double inlines, for C++ */
- inline long double cosl(long double _X)
- {return (_LSin(_X, 1)); }
- inline long double coshl(long double _X)
- {return (_LCosh(_X, 1)); }
- inline long double logl(long double _X)
- {return (_LLog(_X, 0)); }
- inline long double log10l(long double _X)
- {return (_LLog(_X, 1)); }
- inline long double sinl(long double _X)
- {return (_LSin(_X, 0)); }
- inline long double sinhl(long double _X)
- {return (_LSinh(_X, 1)); }
- #else
- /* double macro overrides, for C */
- double cos(double);
- double cosh(double);
- double log(double);
- double log10(double);
- double sin(double);
- double sinh(double);
- #define cos(x) _Sin(x, 1)
- #define cosh(x) _Cosh(x, 1)
- #define log(x) _Log(x, 0)
- #define log10(x) _Log(x, 1)
- #define sin(x) _Sin(x, 0)
- #define sinh(x) _Sinh(x, 1)
- /* float macro overrides, for C */
- float cosf(float);
- float coshf(float);
- float logf(float);
- float log10f(float);
- float sinf(float);
- float sinhf(float);
- #define cosf(x) _FSin(x, 1)
- #define coshf(x) _FCosh(x, 1)
- #define logf(x) _FLog(x, 0)
- #define log10f(x) _FLog(x, 1)
- #define sinf(x) _FSin(x, 0)
- #define sinhf(x) _FSinh(x, 1)
- /* long double macro overrides, for C */
- long double cosl(long double);
- long double coshl(long double);
- long double logl(long double);
- long double log10l(long double);
- long double sinl(long double);
- long double sinhl(long double);
- #define cosl(x) _LSin(x, 1)
- #define coshl(x) _LCosh(x, 1)
- #define logl(x) _LLog(x, 0)
- #define log10l(x) _LLog(x, 1)
- #define sinl(x) _LSin(x, 0)
- #define sinhl(x) _LSinh(x, 1)
- #endif
-
- #endif
-
- #endif /* __MWERKS__ */
-
- /*
- * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
- * Consult your license regarding permissions and restrictions.
- */
-
-